create table Restaurant
(
	 [RestaurantId] int identity(1, 1) primary key
	,[PartnerId] int
	,[RestaurantTypeId] int
	,[RestaurantFullName] nvarchar(128)
	,[RestaurantSortName] nvarchar(128)
	,[RestaurantEnglishName] nvarchar(128)
	,[SortDescription] nvarchar(256)
	,[DetailDescription] nvarchar(max)
	,[BuiltYear] int
	,[ContinentId] int
	,[Nationalid] int
	,[CityId] int
	,[DistrictId] int
	,[WardId] int
	,[Address] nvarchar(128)
	,[RepresentName] nvarchar(128)
	,[RepresentPhone] varchar(32)
	,[RepresentHotline] varchar(32)
	,[RepresentFax] varchar(32)
	,[RepresentEmail] nvarchar(128)
	,[RepresentWebsite] nvarchar(128)
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go

ALTER PROCEDURE RestaurantGet
	@RestaurantId int
AS
SELECT *
FROM [Restaurant]
WHERE [Restaurant].[RestaurantId] = @RestaurantId
GO

ALTER PROCEDURE RestaurantList
AS
SELECT *
FROM [Restaurant]
ORDER BY [RestaurantId] DESC
GO

ALTER PROCEDURE RestaurantInsert
	@PartnerId int
	,@RestaurantTypeId int
	,@RestaurantFullName nvarchar(128)
	,@RestaurantSortName nvarchar(128)
	,@RestaurantEnglishName nvarchar(128)
	,@SortDescription nvarchar(256)
	,@DetailDescription nvarchar(max)
	,@BuiltYear int
	,@ContinentId int
	,@Nationalid int
	,@CityId int
	,@DistrictId int
	,@WardId int
	,@Address nvarchar(128)
	,@RepresentName nvarchar(128)
	,@RepresentPhone varchar(32)
	,@RepresentHotline varchar(32)
	,@RepresentFax varchar(32)
	,@RepresentEmail nvarchar(128)
	,@RepresentWebsite nvarchar(128)
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO Restaurant (
	 [PartnerId]
	,[RestaurantTypeId]
	,[RestaurantFullName]
	,[RestaurantSortName]
	,[RestaurantEnglishName]
	,[SortDescription]
	,[DetailDescription]
	,[BuiltYear]
	,[ContinentId]
	,[Nationalid]
	,[CityId]
	,[DistrictId]
	,[WardId]
	,[Address]
	,[RepresentName]
	,[RepresentPhone]
	,[RepresentHotline]
	,[RepresentFax]
	,[RepresentEmail]
	,[RepresentWebsite]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @PartnerId
	,@RestaurantTypeId
	,@RestaurantFullName
	,@RestaurantSortName
	,@RestaurantEnglishName
	,@SortDescription
	,@DetailDescription
	,@BuiltYear
	,@ContinentId
	,@Nationalid
	,@CityId
	,@DistrictId
	,@WardId
	,@Address
	,@RepresentName
	,@RepresentPhone
	,@RepresentHotline
	,@RepresentFax
	,@RepresentEmail
	,@RepresentWebsite
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

ALTER PROCEDURE RestaurantUpdate
	@RestaurantId int, 
	@PartnerId int, 
	@RestaurantTypeId int, 
	@RestaurantFullName nvarchar(128), 
	@RestaurantSortName nvarchar(128), 
	@RestaurantEnglishName nvarchar(128), 
	@SortDescription nvarchar(256), 
	@DetailDescription nvarchar(max), 
	@BuiltYear int, 
	@ContinentId int, 
	@Nationalid int, 
	@CityId int, 
	@DistrictId int, 
	@WardId int, 
	@Address nvarchar(128), 
	@RepresentName nvarchar(128), 
	@RepresentPhone varchar(32), 
	@RepresentHotline varchar(32), 
	@RepresentFax varchar(32), 
	@RepresentEmail nvarchar(128), 
	@RepresentWebsite nvarchar(128), 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE Restaurant SET
	   [PartnerId] = @PartnerId
	   ,[RestaurantTypeId] = @RestaurantTypeId
	   ,[RestaurantFullName] = @RestaurantFullName
	   ,[RestaurantSortName] = @RestaurantSortName
	   ,[RestaurantEnglishName] = @RestaurantEnglishName
	   ,[SortDescription] = @SortDescription
	   ,[DetailDescription] = @DetailDescription
	   ,[BuiltYear] = @BuiltYear
	   ,[ContinentId] = @ContinentId
	   ,[Nationalid] = @Nationalid
	   ,[CityId] = @CityId
	   ,[DistrictId] = @DistrictId
	   ,[WardId] = @WardId
	   ,[Address] = @Address
	   ,[RepresentName] = @RepresentName
	   ,[RepresentPhone] = @RepresentPhone
	   ,[RepresentHotline] = @RepresentHotline
	   ,[RepresentFax] = @RepresentFax
	   ,[RepresentEmail] = @RepresentEmail
	   ,[RepresentWebsite] = @RepresentWebsite
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [Restaurant].[RestaurantId] = @RestaurantId
GO

ALTER PROCEDURE RestaurantDelete
	@RestaurantId int   
AS
DELETE FROM Restaurant
WHERE [Restaurant].[RestaurantId] = @RestaurantId
GO
